package com.ruoyi.airspaceFlight.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.airspaceFlight.dto.resp.FlypplyAndActionVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.airspaceFlight.domain.FlyAction;
import com.ruoyi.airspaceFlight.service.IFlyActionService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 飞行实施计划Controller
 * 
 * @author ruoyi
 * @date 2023-11-06
 */
@RestController
@RequestMapping("/action")
public class FlyActionController extends BaseController
{
    @Autowired
    private IFlyActionService flyActionService;

    /**
     * 查询飞行实施计划列表
     */
//    @RequiresPermissions("airspaceFlight:action:list")
    @PostMapping ("/list")
    public TableDataInfo list(@RequestBody FlyAction flyAction)
    {
        startPage();
        List<FlyAction> list = flyActionService.selectFlyActionList(flyAction);
        return getDataTable(list);
    }

//    /**
//     * 导出飞行实施计划列表
//     */
//    @RequiresPermissions("airspaceFlight:action:export")
//    @Log(title = "飞行实施计划", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, FlyAction flyAction)
//    {
//        List<FlyAction> list = flyActionService.selectFlyActionList(flyAction);
//        ExcelUtil<FlyAction> util = new ExcelUtil<FlyAction>(FlyAction.class);
//        util.exportExcel(response, list, "飞行实施计划数据");
//    }

    /**
     * 获取飞行实施计划详细信息
     */
    @RequiresPermissions("airspaceFlight:action:query")
    @GetMapping(value = "/{flyActionId}")
    public AjaxResult getInfo(@PathVariable("flyActionId") String flyActionId)
    {
        return AjaxResult.success(flyActionService.selectFlyActionByFlyActionId(flyActionId));
    }

    /**
     * 新增飞行实施计划
     */
    @RequiresPermissions("airspaceFlight:action:add")
    @Log(title = "飞行实施计划", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FlyAction flyAction)
    {
        return toAjax(flyActionService.insertFlyAction(flyAction));
    }

    /**
     * 修改飞行实施计划
     */
    @RequiresPermissions("airspaceFlight:action:edit")
    @Log(title = "飞行实施计划", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FlyAction flyAction)
    {
        return toAjax(flyActionService.updateFlyAction(flyAction));
    }



    /**
     * 删除飞行实施计划
     */
    @RequiresPermissions("airspaceFlight:action:remove")
    @Log(title = "飞行实施计划", businessType = BusinessType.DELETE)
	@DeleteMapping("/{flyActionIds}")
    public AjaxResult remove(@PathVariable String[] flyActionIds)
    {
        return toAjax(flyActionService.deleteFlyActionByFlyActionIds(flyActionIds));
    }
}
